import { useModel } from 'umi'

const useUser = () => {
    const { initialState, setInitialState, refresh } = useModel('@@initialState')

    const user = initialState?.currentUser || {}

    const logout = async () => {
        setInitialState({ currentUser: {} })   
    }

    return {
        user,
        logout,
        refresh,
    }
  }


export default useUser